package main

import "fmt"

// Author : CSR丶WARRIOR
// Time ： 2020/10/14  21:05
// TOOLS : GoLand
// FILENAME : sliceMap.go
// STATEMENT: 结构体与map
type Student struct {
	id   int
	name string
	age  int
	addr string
}

func createMap() {
	var stuMap = make(map[int]Student)
	var p1 Student = Student{
		id:   1,
		name: "张三",
		age:  20,
		addr: "北京",
	}
	var p2 Student = Student{
		id:   2,
		name: "李四",
		age:  23,
		addr: "上海",
	}
	stuMap[1] = p1
	stuMap[2] = p2
	//删除map中的一个student
	delete(stuMap, 1)

	//遍历map
	for key, student := range stuMap {
		fmt.Println(key, student) //2 {2 李四 23 上海}
	}
}
func main() {
	createMap()
}
